package test;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class IntermediaryMethodInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
        before();
        Object feedback=methodProxy.invokeSuper(proxy,args);
        after();
        return "查看代理:"+feedback;
    }
    public void before(){
        System.out.println("前期准备");
        System.out.println("记录");
    }

    public void after(){
        System.out.println("后期跟踪");
        System.out.println("日志。");
    }
}
